﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hexagonal;
using GeoSwarm_Editor.Game;

namespace GeoSwarm_Editor
{
    public class Wave
    {

        /*
         * Creep types:
         *    0 Chomper
         *    1 Spinner
         *    2 Wiggle
         *    3 Star
         *    4 Cubic
         *    5 Pulsar
         *    6 Swarm
         */

        private Hex spawnHex;
        private List<Creep> creeps;
        private bool concurrent = false;

        #region Constructors

        public Wave(Hex spawnHex)
        {
            creeps = new List<Creep>();
            this.spawnHex = spawnHex;
            AddCreep(0, 8);
        }

        #endregion

        #region Methods

        public Creep AddCreep(int typeID, int count)
        {
            Creep creep = new Creep(typeID, count);
            creeps.Add(creep);
            return creep;
        }

        public void RemoveCreep(int index)
        {
            creeps.RemoveAt(index);
        }

        public void ClearCreeps()
        {
            creeps.Clear();
        }

        public void AddCreeps(System.Windows.Forms.ListBox.ObjectCollection creeps)
        {
            foreach (Creep curr in creeps)
                this.creeps.Add(curr);
        }

        #endregion

        #region Properties

        public bool Concurrent
        {
            get
            {
                return concurrent;
            }
            set
            {
                concurrent = value;
            }
        }

        public Hex SpawnHex
        {
            get
            {
                return spawnHex;
            }
            set
            {
                spawnHex = value;
            }
        }

        public Creep[] Creeps
        {
            get
            {
                return creeps.ToArray();
            }
        }

        #endregion

        public override string ToString()
        {
            string outStr = "";
            int i = 1;
            foreach (Creep curCreep in creeps)
            {
                if (i != creeps.Count)
                    outStr += curCreep.ToString() + ", ";
                else
                    outStr += curCreep.ToString();
                i++;
            }
            return outStr;
        }
    }
}
